package servlet;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import anuncio.Anuncio;
import anuncio.ControlAnuncio;

/**
 * Servlet implementation class PesquisarTodosAnuncios
 */
public class PesquisarTodosAnuncios extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PesquisarTodosAnuncios() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ControlAnuncio ctrl = new ControlAnuncio();
		Collection<Anuncio> coll = ctrl.todosanuncios();
		
		HttpSession session = request.getSession();
		session.setAttribute("lista", coll);
		response.sendRedirect("TodosAnuncios.jsp");
		
	}

}
